import {
    Action
} from 'redux';

import * as types from './../types/location';

const initState = {
    current: {},
    list:[],
    hots:[]
};

export default (state = initState, action: Action) => {
    const {
        type,
        data
    } = action;

    switch (type) {
        case types.getCurrentLocation: {
            state.current = data;
            return {
                ...state
            }
        }
        case types.getLocationByKeyword :{
            state.list = data;
            return {
                ...state
            }
        }
        case types.getHotCity :{
            state.hots = data;
            return {
                ...state
            }
        }
    }
    return state;
}